package cn.liontalk.consumer;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.stereotype.Component;

/**
 * @author: 周哲
 * @package: cn.liontalk.consumer
 * @description: Info日志消息的消费者
 * @date: 2019/1/10 15:14
 * @version: V1.0
 */
@Component
@RabbitListener(
        bindings = @QueueBinding(value = @Queue(value = "${mq.config.info.queue}", autoDelete = "false"),
                exchange = @Exchange(value = "${mq.config.exchange}", type = ExchangeTypes.DIRECT,autoDelete = "false" ),
                key = "${mq.config.queue.info.routing.key}"
        )
)
public class InfoConsumer {
    /**
     * @RabbitListener  bindings:绑定队列
     * @QueueBinding  value 绑定队列名称
     *                exchange 配置交换器
     *                 key  路由键
     *
     * @Queue value:配置队列的名称
     *        autoDelete： 是否是一个可以删除的临时队列
     *
     * @Exchange value:为交换器起一个名称
     *            type: 指定具体的交换器的类型
     *
     * 接收消息的方法,采用消息队列监听的机制
     *
     * @param message 消息内容
     */
    @RabbitHandler
    public void process(String message) {
        System.out.println("InfoConsumer Receive : " + message);
    }
}
